package model

import (
	"database/sql"
	"time"

	"github.com/guregu/null"
	"github.com/satori/go.uuid"
)

var (
	_ = time.Second
	_ = sql.LevelDefault
	_ = null.Bool{}
	_ = uuid.UUID{}
)

/*
DB Table Details
-------------------------------------


CREATE TABLE "genres"
(
    [GenreId] INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
    [Name] NVARCHAR(120)
)

JSON Sample
-------------------------------------
{    "name": "hlRLqaFiXUwxNAwiIBQQgRULp",    "genre_id": 1}



*/

// Genres struct is a row record of the genres table in the main database
type Genres struct {
	//[ 0] GenreId                                        integer              null: false  primary: true   isArray: false  auto: true   col: integer         len: -1      default: []
	GenreID int32 `gorm:"primary_key;AUTO_INCREMENT;column:GenreId;type:integer;" json:"genre_id"`
	//[ 1] Name                                           nvarchar(120)        null: true   primary: false  isArray: false  auto: false  col: nvarchar        len: 120     default: []
	Name sql.NullString `gorm:"column:Name;type:nvarchar;size:120;" json:"name"`
}

var genresTableInfo = &TableInfo{
	Name: "genres",
	Columns: []*ColumnInfo{

		{
			Index:              0,
			Name:               "GenreId",
			Comment:            ``,
			Notes:              ``,
			Nullable:           false,
			DatabaseTypeName:   "integer",
			DatabaseTypePretty: "integer",
			IsPrimaryKey:       true,
			IsAutoIncrement:    true,
			IsArray:            false,
			ColumnType:         "integer",
			ColumnLength:       -1,
			GoFieldName:        "GenreID",
			GoFieldType:        "int32",
			JSONFieldName:      "genre_id",
			ProtobufFieldName:  "genre_id",
			ProtobufType:       "int32",
			ProtobufPos:        1,
		},

		{
			Index:              1,
			Name:               "Name",
			Comment:            ``,
			Notes:              ``,
			Nullable:           true,
			DatabaseTypeName:   "nvarchar",
			DatabaseTypePretty: "nvarchar(120)",
			IsPrimaryKey:       false,
			IsAutoIncrement:    false,
			IsArray:            false,
			ColumnType:         "nvarchar",
			ColumnLength:       120,
			GoFieldName:        "Name",
			GoFieldType:        "sql.NullString",
			JSONFieldName:      "name",
			ProtobufFieldName:  "name",
			ProtobufType:       "string",
			ProtobufPos:        2,
		},
	},
}

// TableName sets the insert table name for this struct type
func (g *Genres) TableName() string {
	return "genres"
}

// BeforeSave invoked before saving, return an error if field is not populated.
func (g *Genres) BeforeSave() error {
	return nil
}

// Prepare invoked before saving, can be used to populate fields etc.
func (g *Genres) Prepare() {
}

// Validate invoked before performing action, return an error if field is not populated.
func (g *Genres) Validate(action Action) error {
	return nil
}

// TableInfo return table meta data
func (g *Genres) TableInfo() *TableInfo {
	return genresTableInfo
}
